//
//  ColumnCollectionReusableView.m
//  UI___14HomeWork 礼物说分类界面
//
//  Created by 冀永金 on 16/8/2.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ColumnCollectionReusableView.h"
#import "ColumCollectionViewCell.h"
@interface ColumnCollectionReusableView ()<UICollectionViewDelegate,UICollectionViewDataSource>


@end

@implementation ColumnCollectionReusableView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 30)];
        [self addSubview:_label];
        _label.text = @"栏目";
        _label.font = [UIFont systemFontOfSize:14];
        _label.textColor = [UIColor lightGrayColor];
       // _label.backgroundColor = [UIColor cyanColor];
        self.button = [UIButton buttonWithType:UIButtonTypeSystem];
        _button.frame = CGRectMake(310, 10, 80, 30);
        [self addSubview:_button];
        //_button.backgroundColor = [UIColor cyanColor];
        [_button setTitle:@"查看全部>" forState:UIControlStateNormal];
        _button.titleLabel.font = [UIFont systemFontOfSize:13];
        [_button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [self createCollectionView];
    }
    return self;
}
- (void)createCollectionView {
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.itemSize = CGSizeMake((self.bounds.size.width - 20) / 1.3, (self.bounds.size.height - 75) / 3);
    layout.sectionInset = UIEdgeInsetsMake(10, 10, 0, 0);
    layout.minimumLineSpacing = 10;
    layout.minimumInteritemSpacing = 10;
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    UICollectionView *collection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 45, self.bounds.size.width, 305) collectionViewLayout:layout];
    [self addSubview:collection];
    collection.delegate = self;
    collection.dataSource = self;
    [collection registerClass:[ColumCollectionViewCell class] forCellWithReuseIdentifier:@"pool"];
    collection.backgroundColor = [UIColor whiteColor];
    collection.showsHorizontalScrollIndicator = NO;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 11;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    ColumCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"pool" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor orangeColor];
    return cell;
}
@end
